-- probability_damage
-- create by shuzy
-- 道具：  m%概率造成n%额外伤害

return {
    apply = function(source, target, classId, value)
        -- 固定伤害

        -- 传入攻击者信息
        local assailantInfo = {
            ["property_id"] = classId,
        };

        -- 道具伤害加成
        local damage = value[1];
        if PropertyM.query(classId, "target") ~= PROPERTY_SELF then
            local prop = PropM.combine(source, "property_damage", 1);
            damage = PropM.apply(prop, damage);
        end

        if DungeonM.getRandSeed("probability_damage1") % 1000 <= value[2] then
            damage = math.modf(damage + damage * value[3] / 1000);
        end

        -- 修正伤害值
        damage =  PropertyM.fixPropertyDamage(source, target, classId, damage);

        if ItemM.query(classId, "apply") == "damage_and_drop" then
            -- 会掉落道具
            CombatM.doDamage(source, target, damage, 0, true, { assailantInfo = assailantInfo, });
        else
            CombatM.doDamage(source, target, damage, 0, false, { assailantInfo = assailantInfo, });
        end

        -- 抛出使用道具攻击事件
        EventMgr.fire(event.PROPERTY_ATTACK, { ["classId"] = classId, ["target"] = target, ["source"] = source});
    end,
};
